package butines.game.state;

import butines.core.Vector2f;
import butines.core.game.message.Message;
import butines.game.Unit;

public class GlobalUnitState extends AbstractState {

	private static final GlobalUnitState instance = new GlobalUnitState();
	
	public static GlobalUnitState getInstance() {
		return instance;
	}

	@Override
	public boolean onMessage(Unit owner, Message message) {
		switch ((MessageType)message.getType()) {
			case UNIT_MOVE: {
				Vector2f targetPoint = message.getInfo();
				owner.move(targetPoint);
				return true;
			}
			case UNIT_ATTACK: {
				Unit enemy = message.getInfo();
				owner.attack(enemy);
				return true;
			}
		}
		return false;
	}
}
